function login_submit(){	

	var options = {
			url : '/login',
			beforeSubmit:  checkForm,
			dataType: "json",
			type:"post",
			success : function(ret) {
				if(ret.msg==''){
					$('#dialog').dialog({
						modal:true,
						title:'系统提示',
						buttons:{"确定":function(){$(this).dialog("close");}},
						close: function() {
							location=ret.data.url;
						}
					});
					$("#msg").html("登陆成功<br>3秒后自动跳转"+ret.sycDz);
					setTimeout(function(){location=ret.data.url;},3000);
				}else{
					$('#dialog').dialog({
						modal:true,
						title:'系统提示',
						buttons:{"确定":function(){$(this).dialog("close");}},
						close: function() {
							document.getElementById("imgCode").src = "/yanzheng/index/?" + Math.random();
						}
					}); 
					$("#msg").html(ret.msg);
				}
			}
		};
		$("#login_form").ajaxSubmit(options);
		return false;		
}

function clearText(input){
	if(input.value=='用户名/邮箱' || input.value=='请输入邮箱' || input.value=='请输入手机号码'|| input.value=='请输入验证码'){
		input.value="";
	}
}
function setText(input,txt){
	if(input.value==''){
		input.value=txt;
	}
}

function showPwd(){
	$('#pwdtxt').css('display','none');
	$('#password').css('display','');
	$('#password').focus();
}
function showPwdVal(){
	if($('#password').val()==''){
		$('#password').css('display','none');
		$('#pwdtxt').css('display','');	
	}
}

function checkForm(){
	$('#dialog').dialog({
		modal:true,
		title:'系统提示'
	}); 
	$("#msg").html("正在登录...");
	var err = '';
	if($('#username').val()=='' || $('#username').val()=='用户名/邮箱'){
		err = '请输入用户名/邮箱';
	}else if($('#password').val()=='' || $('#password').val()=='请输入密码'){
		err = '请输入密码';
	}else if($('#captcha').val()=='' || $('#username').val()=='请输入验证码'){
		err = '请输入验证码';
	}
	
	if(err==''){
		return true;
	}else{
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
			close: function() {
				document.getElementById("imgCode").src = "/yanzheng/index/?" + Math.random();
			}
		}); 
		$("#msg").html(err);
		return false;
	}
}